package bl.history;

import java.net.MalformedURLException;
import java.rmi.AlreadyBoundException;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;

import po.SystemLogPo;
import server.boot.ServiceLoader;
import vo.SystemLogVo;
import client.boot.BLServiceManager;
import blservice.history.SystemLogBLService;
import db.Database;
import db.history.SystemLogDB;
import dbservice.history.SystemLogDBService;

public class SystemLogBLDriver {

	SystemLogDBService db;
	SystemLogBLService bl;
	
	public static void main(String[] args) throws MalformedURLException, RemoteException, SQLException, NotBoundException, AlreadyBoundException{
		SystemLogBLDriver d=new SystemLogBLDriver();
		d.drive();
	}
	
	void drive() throws SQLException, MalformedURLException, RemoteException, NotBoundException, AlreadyBoundException{
		Database.iniDatabase("localhost", 3306, "seac2", "seac2", "seac2");
		Connection c=Database.getConnection();
		Statement s=c.createStatement();
		s.execute("drop table if exists systemlog ;");
		ServiceLoader.iniServiceLoader();
		BLServiceManager.setServerIP("localhost");
		bl=BLServiceManager.getSystemLogBLService();
		
		db=new SystemLogDB();
		db.add(new SystemLogPo("driver", "drive", "test"));
		
		List<SystemLogVo> vo=bl.get();
		for(SystemLogVo o:vo){
			System.out.println(o.getDate());
			System.out.println(o.getOperator());
			System.out.println(o.getOperation());
			System.out.println(o.getObject());
		}
		System.exit(0);
	}

}
